import static java.lang.Math.max;
/**
 * 贪心算法-买卖股票最佳时机II-力扣122
 */
public class Practice_12 {
    public static void main(String[] args) {
        int[] prices = {7};
        int result = maxProfit(prices);
        System.out.println(result);
    }
    public static int maxProfit(int[] prices) {
        int result = 0;
        if(prices.length==1){
            return result;
        }

        for (int i = 1; i < prices.length; i++) {
            result = result + max(prices[i] - prices[i - 1], 0);
        }
        return result;
    }

}
